namespace FutureApp.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class ShopGoods2 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.FutureGoodsPrices",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Price = c.Decimal(nullable: false, precision: 18, scale: 2),
                        SalePrice = c.Decimal(nullable: false, precision: 18, scale: 2),
                        BottomPrice = c.Decimal(nullable: false, precision: 18, scale: 2),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_GoodsPrice_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.FutureUsers", t => t.CreatorUserId)
                .ForeignKey("dbo.FutureUsers", t => t.DeleterUserId)
                .ForeignKey("dbo.FutureGoods", t => t.Id)
                .ForeignKey("dbo.FutureUsers", t => t.LastModifierUserId)
                .Index(t => t.Id)
                .Index(t => t.DeleterUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.CreatorUserId);
            
            CreateTable(
                "dbo.FutureGoodsStocks",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        Quantity = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.FutureGoods", t => t.Id)
                .Index(t => t.Id);
            
            CreateTable(
                "dbo.FutureGoodsStockTransactions",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        GoodsId = c.Guid(nullable: false),
                        Direction = c.Int(nullable: false),
                        Quantity = c.Int(nullable: false),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.FutureUsers", t => t.CreatorUserId)
                .ForeignKey("dbo.FutureGoods", t => t.GoodsId)
                .Index(t => t.GoodsId)
                .Index(t => t.CreatorUserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.FutureGoodsStockTransactions", "GoodsId", "dbo.FutureGoods");
            DropForeignKey("dbo.FutureGoodsStockTransactions", "CreatorUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureGoodsStocks", "Id", "dbo.FutureGoods");
            DropForeignKey("dbo.FutureGoodsPrices", "LastModifierUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureGoodsPrices", "Id", "dbo.FutureGoods");
            DropForeignKey("dbo.FutureGoodsPrices", "DeleterUserId", "dbo.FutureUsers");
            DropForeignKey("dbo.FutureGoodsPrices", "CreatorUserId", "dbo.FutureUsers");
            DropIndex("dbo.FutureGoodsStockTransactions", new[] { "CreatorUserId" });
            DropIndex("dbo.FutureGoodsStockTransactions", new[] { "GoodsId" });
            DropIndex("dbo.FutureGoodsStocks", new[] { "Id" });
            DropIndex("dbo.FutureGoodsPrices", new[] { "CreatorUserId" });
            DropIndex("dbo.FutureGoodsPrices", new[] { "LastModifierUserId" });
            DropIndex("dbo.FutureGoodsPrices", new[] { "DeleterUserId" });
            DropIndex("dbo.FutureGoodsPrices", new[] { "Id" });
            DropTable("dbo.FutureGoodsStockTransactions");
            DropTable("dbo.FutureGoodsStocks");
            DropTable("dbo.FutureGoodsPrices",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_GoodsPrice_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
        }
    }
}
